SAS日期格式大全
--------------------------------

# SAS日期格式大全

根据初始月份mon定义日期格式。
```
%let mon=202001;
data _null_;
   call symput("mon_b",put(intnx("month",input("&mon.",yymmn6.),0),yymmddn8.));
   call symput("mon_e",put(intnx("month",input("&mon.",yymmn6.),0,"end"),yymmddn8.));
run;
```

# SAS代码调整逻辑回归模型截距项
```
data a;
	set b;
	if ranuni(seed)<=labelrate then label=1;
	else label=0;
	lnodds=log(oldprob/(1-oldprob));
run;
proc logistic data = b descending;
	model label=/ctabel details offset = lnodds;
	output out=c pred=newprob;
run;
```

# SAS代码统计星座和生肖

```sql
proc format;
value con 321-419=‘白羊座’
420-520=‘金牛座’
521-621=‘双子座’
622-722=‘巨蟹座’
723-822=‘狮子座’
823-922=‘处女座’
923-1023=‘天秤座’
1024-1122=‘天蝎座’
1123-1221=‘射手座’
1222-1231=‘魔羯座’
11-119=‘魔羯座’
120-218=‘水瓶座’
219-320=‘双鱼座’;
value zod 4=‘鼠’
5=‘牛’
6=‘虎’
7=‘兔’
8=‘龙’
9=‘蛇’
10=‘马’
11=‘羊’
0=‘猴’
1=‘鸡’
2=‘狗’
3=‘猪’;
run;
%let idno=‘XXX’;
data null;
if length(&idno)=15 then do;
con=substr(&idno,9,4);
zod=put(mod(input(substr(&idno,7,2),best.)+1900,12),zod.);
end;
else do;
con=put(input(substr(&idno,11,4),best.),con.);
zod=put(mod(input(substr(&idno,7,4),best.),12),zod.);
end;
put ‘星座：’ con / ‘生肖：’ zod ;
run;
```



# 多元自适应回归算法-MARS
```sas
ods graphics on;
proc adaptivereg data=train
    plots=all details=BASEs;
    model Y=x1 x2/additive dist=binomial;
    score data=trian out=train_score;
    score data=valid out=valid_score;
run;
```

R语言mars代码
```r
train.mod <- earth(label ~ x1 + x2+x3+x4, data=train, degree=2)
coef(train.mod)
```
[参考链接](https://mp.weixin.qq.com/s?__biz=MzU1MTMyNzkyNg==&mid=2247484071&idx=1&sn=a80ed3162c47ab88bf765fa667dfc813&chksm=fb92437ecce5ca68166256ea23f4e20eea826808743e0402930d8122d15bff343b548889ecc8&scene=127&ascene=0&devicetype=android-29&version=27001537&nettype=WIFI&abtest_cookie=AAACAA==&lang=zh_CN&exportkey=A4S7NzFOBdhEWqkr/Ozph8w=&pass_ticket=NOpBHM/vNChYtunZXJdu2xx5yaiexxwCJh0EwgY09Y6V6t9GcCHlBX1bj6CrKktI&wx_header=1)
[官方链接](http://www.milbo.users.sonic.net/earth/)